#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef struct
{
    vector<char> cards;
} Cards;

Cards * cards_add_card(Cards *cards, char card)
{
    cards->cards.push_back(card);
    return cards;
}

Cards * cards_output_info(Cards *cards, char card)
{
}

typedef struct
{
    char role;
    Cards cards;
} Player;

Player * player_add_card(Player *player, char card)
{
    cards_add_card(&(player->cards), card);
    return player;
}

typedef struct
{
    Cards cards;
    vector<Player> players;
} Game;

Game * game_output_info(Game * game)
{
    int i, j;
    for (i = 0; i < game->players.size(); i++)
    {
        Player *current = &game->players[i];
        cout << current->role << " ";
        for (j = 0; j < current->cards; j++)
        {
            /* code */
        }
        
    }
}

int main(int argc, char const *argv[])
{
    Player player_temp;
    Game game;
    int i, j, k, n, m;
    char temp;

    cin >> n >> m;
    for (i = 0; i < n; i++)
    {
        cin >> player_temp.role;
        cin >> temp;
        for (j = 0; j < 4; j++)
        {
            cin >> temp;
            player_add_card(&player_temp, temp);
        }
        game.players.push_back(player_temp);
    }
    
    for (i = 0; i < m; i++)
    {
        cin >> temp;
        cards_add_card(&(game.cards), temp);
    }
    
    game_output_info(&game);

    return 0;
}
